<?php defined('BASEPATH') OR exit('No direct script access allowed');
/**
 * Description: 搜索关键字
 *
 * @author      Eden
 * @datetime    2016/12/17 17:29
 * @copyright   Beijing CmsTop Technology Co.,Ltd.
 */

class Keyword_Model extends API_Model
{

    /**
     * 初始化
     */
    public function __construct()
    {
        parent::__construct();
    }

    public function run($params)
    {
        $send['state'] = true;
        $q = $this->db->order_by('times', 'DESC')->limit(10)->get('search');
        $rows = $q->result_array();

        $keys = [];
        if(!empty($rows)) foreach($rows as $item) {
            $keys[] = $item['keyword'];
        }

        $send['data'] = [
            'keyword' => $keys
        ];
        $this->output->send($send);
    }
}
